//package com.icangya.interceptor;
//
//import com.icangya.Value.FootBall;
//import com.icangya.Value.StaticValue;
//import com.icangya.domain.Admin;
//import com.icangya.domain.BadUserDO;
//import com.icangya.domain.User;
//import com.icangya.service.IAdminUserService;
//import com.icangya.service.IBadUserService;
//import org.apache.log4j.Logger;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.List;
//
//import static com.icangya.Value.StaticValue.ADMIN_USER_SESSION;
//
///**
// * Created by 王小红 on 2017/5/16.
// */
//public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
//
//    private Logger logger = Logger.getLogger(this.getClass());
//
//    @Autowired
//    private IAdminUserService iAdminUserService;
//
//    @Autowired
//    private IBadUserService iBadUserService;
//    //@Autowired
//   // IUserDAO iUserDAO;
//
//    @Override
//    public boolean preHandle(HttpServletRequest request,
//                             HttpServletResponse response, Object handler) throws Exception {
//        /** 拦截到用户的请求了 */
//        String requestUrl = request.getRequestURL().toString();
//        /** */
//        logger.debug("requestUrl:" + requestUrl);
//        Admin user = (Admin) request.getSession().getAttribute(ADMIN_USER_SESSION);
//
//        if(iAdminUserService.getSwitch().getStatus()==0){
//            try {
//                response.sendRedirect(StaticValue.WX.BASE_URL+"/sys/wh.html");
//                return false;
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }
//
//        if (StaticValue.WX.BASE_URL.equals(requestUrl)||(StaticValue.WX.BASE_URL+"/").equals(requestUrl)){
//            //如果地址等于www.mnuocom.com,则跳转到百度
//            response.sendRedirect(StaticValue.WX.NO_URL);
//            return false;
//
//        }
//        /** 判断session是否存在用户,如果存在说明用户已经登录了,应该放行 */
//        if (user != null) {
//
//            //拉黑用户检测，并且拒绝其访问
////            List<BadUserDO> badUserDOList = iBadUserService.getBadUserByOpenid(user.getOpenId());
////            if (badUserDOList.size() > 0){
////                response.sendRedirect(StaticValue.WX.NO_URL);
////                return false;
////            }
//            response.sendRedirect(StaticValue.WX.BASE_URL + "/Shopping_Mall/index.html");
//            return false;
//        } else {
//
//            return true;
//        }
//
//    }
//
//
//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
//            throws Exception {
//    }
//
//
//}
